using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Vouchers;
using Lists;
using BasicForms;
using System.Collections;

namespace KeToanTongHop
{
    public partial class FrmDanhSachPhieuBuTruCongNo : FrmDanhSachChungTu
    {
        public FrmDanhSachPhieuBuTruCongNo()
        {
            InitializeComponent();
            _DieuKienTimKiem.LoaiChungTu = DanhMucLoaiChungTu.Instance.GetByMa("PhieuBuTruCongNo");
        }

        void frm_RequestAddNew()
        {
            try
            {
                FrmEditPhieuBuTruCongNo frm = new FrmEditPhieuBuTruCongNo(_DanhSachChungTu.CreateNew(_DieuKienTimKiem.LoaiChungTu));
                frm.RequestAddNew += new FrmEditChungTu.OnRequestAddNew(frm_RequestAddNew);
                frm.Show();
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }

        public override void CreateNew()
        {
            try
            {
                FrmEditPhieuBuTruCongNo frm = new FrmEditPhieuBuTruCongNo(_DanhSachChungTu.CreateNew(_DieuKienTimKiem.LoaiChungTu));
                frm.RequestAddNew += new FrmEditChungTu.OnRequestAddNew(frm_RequestAddNew);
                frm.Show();
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }
        protected override void Edit()
        {
            try
            {
                ArrayList arDeletedChungTu = new ArrayList();
                foreach (int index in gridViewDsChungTu.GetSelectedRows())
                {
                    arDeletedChungTu.Add(_DanhSachChungTu.GetByDataRow(gridViewDsChungTu.GetDataRow(index)));
                }
                gridViewDsChungTu.BeginUpdate();
                foreach (ChungTu chungTu in arDeletedChungTu)
                {
                    FrmEditPhieuBuTruCongNo frm = new FrmEditPhieuBuTruCongNo(chungTu);
                    frm.RequestAddNew += new FrmEditChungTu.OnRequestAddNew(frm_RequestAddNew);
                    frm.Show();
                }
                gridViewDsChungTu.EndUpdate();
            }
            catch (Exception ex)
            {
                BasicForms.FrmExceptionNotifier.ShowAndLog(ex);
            }
        }
    }
}

